//
//  FFTabPageView.swift
//  ZgwApp
//
//  Created by li on 2025-02-10.
//

import SwiftUI

struct FFLazyView<D: Hashable, P: View>: View {
	
	init(data: FFLazyViewModel<D>, content: @escaping (D) -> P) {
		self._data = State(wrappedValue: data)
		self.content = content
	}
	
	@State var data: FFLazyViewModel<D>
	
	@ViewBuilder
	var content: (D) -> P
	var body: some View {

		ZStack {
			if data.viewDidLoad {
				content(data.data)
			}
		}
	}
}

class FFLazyViewModel<D: Hashable>: NSObject, ObservableObject {
	
	init(data: D) {
		
		self.data = data
	}
	
	@Published var viewDidLoad: Bool = false
	let data: D
}

